<?php

namespace GotchaDatabase\om;

use \Criteria;
use \Exception;
use \ModelCriteria;
use \ModelJoin;
use \PDO;
use \Propel;
use \PropelCollection;
use \PropelException;
use \PropelObjectCollection;
use \PropelPDO;
use GotchaDatabase\GotchaContent;
use GotchaDatabase\GotchaContentPeer;
use GotchaDatabase\GotchaContentQuery;
use GotchaDatabase\GotchaPages;
use GotchaDatabase\GotchaUsers;

/**
 * Base class that represents a query for the 'Gotcha_Content' table.
 *
 *
 *
 * @method GotchaContentQuery orderById($order = Criteria::ASC) Order by the Id column
 * @method GotchaContentQuery orderByStrongName($order = Criteria::ASC) Order by the Strong_Name column
 * @method GotchaContentQuery orderByTitle($order = Criteria::ASC) Order by the Title column
 * @method GotchaContentQuery orderByText($order = Criteria::ASC) Order by the Text column
 * @method GotchaContentQuery orderByCreationDate($order = Criteria::ASC) Order by the Creation_Date column
 * @method GotchaContentQuery orderByCreationTitle($order = Criteria::ASC) Order by the Creation_Title column
 * @method GotchaContentQuery orderByGotchaUsersId($order = Criteria::ASC) Order by the Gotcha_Users_Id column
 *
 * @method GotchaContentQuery groupById() Group by the Id column
 * @method GotchaContentQuery groupByStrongName() Group by the Strong_Name column
 * @method GotchaContentQuery groupByTitle() Group by the Title column
 * @method GotchaContentQuery groupByText() Group by the Text column
 * @method GotchaContentQuery groupByCreationDate() Group by the Creation_Date column
 * @method GotchaContentQuery groupByCreationTitle() Group by the Creation_Title column
 * @method GotchaContentQuery groupByGotchaUsersId() Group by the Gotcha_Users_Id column
 *
 * @method GotchaContentQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method GotchaContentQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method GotchaContentQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method GotchaContentQuery leftJoinGotchaUsers($relationAlias = null) Adds a LEFT JOIN clause to the query using the GotchaUsers relation
 * @method GotchaContentQuery rightJoinGotchaUsers($relationAlias = null) Adds a RIGHT JOIN clause to the query using the GotchaUsers relation
 * @method GotchaContentQuery innerJoinGotchaUsers($relationAlias = null) Adds a INNER JOIN clause to the query using the GotchaUsers relation
 *
 * @method GotchaContentQuery leftJoinGotchaPages($relationAlias = null) Adds a LEFT JOIN clause to the query using the GotchaPages relation
 * @method GotchaContentQuery rightJoinGotchaPages($relationAlias = null) Adds a RIGHT JOIN clause to the query using the GotchaPages relation
 * @method GotchaContentQuery innerJoinGotchaPages($relationAlias = null) Adds a INNER JOIN clause to the query using the GotchaPages relation
 *
 * @method GotchaContent findOne(PropelPDO $con = null) Return the first GotchaContent matching the query
 * @method GotchaContent findOneOrCreate(PropelPDO $con = null) Return the first GotchaContent matching the query, or a new GotchaContent object populated from the query conditions when no match is found
 *
 * @method GotchaContent findOneById(int $Id) Return the first GotchaContent filtered by the Id column
 * @method GotchaContent findOneByStrongName(string $Strong_Name) Return the first GotchaContent filtered by the Strong_Name column
 * @method GotchaContent findOneByTitle(string $Title) Return the first GotchaContent filtered by the Title column
 * @method GotchaContent findOneByText(string $Text) Return the first GotchaContent filtered by the Text column
 * @method GotchaContent findOneByCreationDate(string $Creation_Date) Return the first GotchaContent filtered by the Creation_Date column
 * @method GotchaContent findOneByCreationTitle(string $Creation_Title) Return the first GotchaContent filtered by the Creation_Title column
 * @method GotchaContent findOneByGotchaUsersId(int $Gotcha_Users_Id) Return the first GotchaContent filtered by the Gotcha_Users_Id column
 *
 * @method array findById(int $Id) Return GotchaContent objects filtered by the Id column
 * @method array findByStrongName(string $Strong_Name) Return GotchaContent objects filtered by the Strong_Name column
 * @method array findByTitle(string $Title) Return GotchaContent objects filtered by the Title column
 * @method array findByText(string $Text) Return GotchaContent objects filtered by the Text column
 * @method array findByCreationDate(string $Creation_Date) Return GotchaContent objects filtered by the Creation_Date column
 * @method array findByCreationTitle(string $Creation_Title) Return GotchaContent objects filtered by the Creation_Title column
 * @method array findByGotchaUsersId(int $Gotcha_Users_Id) Return GotchaContent objects filtered by the Gotcha_Users_Id column
 *
 * @package    propel.generator.gotcha.om
 */
abstract class BaseGotchaContentQuery extends ModelCriteria
{
    /**
     * Initializes internal state of BaseGotchaContentQuery object.
     *
     * @param     string $dbName The dabase name
     * @param     string $modelName The phpName of a model, e.g. 'Book'
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     */
    public function __construct($dbName = 'codenova_gotcha', $modelName = 'GotchaDatabase\\GotchaContent', $modelAlias = null)
    {
        parent::__construct($dbName, $modelName, $modelAlias);
    }

    /**
     * Returns a new GotchaContentQuery object.
     *
     * @param     string $modelAlias The alias of a model in the query
     * @param   GotchaContentQuery|Criteria $criteria Optional Criteria to build the query from
     *
     * @return GotchaContentQuery
     */
    public static function create($modelAlias = null, $criteria = null)
    {
        if ($criteria instanceof GotchaContentQuery) {
            return $criteria;
        }
        $query = new GotchaContentQuery();
        if (null !== $modelAlias) {
            $query->setModelAlias($modelAlias);
        }
        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }

    /**
     * Find object by primary key.
     * Propel uses the instance pool to skip the database if the object exists.
     * Go fast if the query is untouched.
     *
     * <code>
     * $obj = $c->findPk(array(12, 34), $con);
     * </code>
     *
     * @param array $key Primary key to use for the query
                         A Primary key composition: [$Id, $Gotcha_Users_Id]
     * @param     PropelPDO $con an optional connection object
     *
     * @return   GotchaContent|GotchaContent[]|mixed the result, formatted by the current formatter
     */
    public function findPk($key, $con = null)
    {
        if ($key === null) {
            return null;
        }
        if ((null !== ($obj = GotchaContentPeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
            // the object is already in the instance pool
            return $obj;
        }
        if ($con === null) {
            $con = Propel::getConnection(GotchaContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
         || $this->map || $this->having || $this->joins) {
            return $this->findPkComplex($key, $con);
        } else {
            return $this->findPkSimple($key, $con);
        }
    }

    /**
     * Find object by primary key using raw SQL to go fast.
     * Bypass doSelect() and the object formatter by using generated code.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return                 GotchaContent A model object, or null if the key is not found
     * @throws PropelException
     */
    protected function findPkSimple($key, $con)
    {
        $sql = 'SELECT `Id`, `Strong_Name`, `Title`, `Text`, `Creation_Date`, `Creation_Title`, `Gotcha_Users_Id` FROM `Gotcha_Content` WHERE `Id` = :p0 AND `Gotcha_Users_Id` = :p1';
        try {
            $stmt = $con->prepare($sql);
            $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
            $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
        }
        $obj = null;
        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $obj = new GotchaContent();
            $obj->hydrate($row);
            GotchaContentPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
        }
        $stmt->closeCursor();

        return $obj;
    }

    /**
     * Find object by primary key.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return GotchaContent|GotchaContent[]|mixed the result, formatted by the current formatter
     */
    protected function findPkComplex($key, $con)
    {
        // As the query uses a PK condition, no limit(1) is necessary.
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKey($key)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    }

    /**
     * Find objects by primary key
     * <code>
     * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
     * </code>
     * @param     array $keys Primary keys to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return PropelObjectCollection|GotchaContent[]|mixed the list of results, formatted by the current formatter
     */
    public function findPks($keys, $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKeys($keys)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->format($stmt);
    }

    /**
     * Filter the query by primary key
     *
     * @param     mixed $key Primary key to use for the query
     *
     * @return GotchaContentQuery The current query, for fluid interface
     */
    public function filterByPrimaryKey($key)
    {
        $this->addUsingAlias(GotchaContentPeer::ID, $key[0], Criteria::EQUAL);
        $this->addUsingAlias(GotchaContentPeer::GOTCHA_USERS_ID, $key[1], Criteria::EQUAL);

        return $this;
    }

    /**
     * Filter the query by a list of primary keys
     *
     * @param     array $keys The list of primary key to use for the query
     *
     * @return GotchaContentQuery The current query, for fluid interface
     */
    public function filterByPrimaryKeys($keys)
    {
        if (empty($keys)) {
            return $this->add(null, '1<>1', Criteria::CUSTOM);
        }
        foreach ($keys as $key) {
            $cton0 = $this->getNewCriterion(GotchaContentPeer::ID, $key[0], Criteria::EQUAL);
            $cton1 = $this->getNewCriterion(GotchaContentPeer::GOTCHA_USERS_ID, $key[1], Criteria::EQUAL);
            $cton0->addAnd($cton1);
            $this->addOr($cton0);
        }

        return $this;
    }

    /**
     * Filter the query on the Id column
     *
     * Example usage:
     * <code>
     * $query->filterById(1234); // WHERE Id = 1234
     * $query->filterById(array(12, 34)); // WHERE Id IN (12, 34)
     * $query->filterById(array('min' => 12)); // WHERE Id >= 12
     * $query->filterById(array('max' => 12)); // WHERE Id <= 12
     * </code>
     *
     * @param     mixed $id The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return GotchaContentQuery The current query, for fluid interface
     */
    public function filterById($id = null, $comparison = null)
    {
        if (is_array($id)) {
            $useMinMax = false;
            if (isset($id['min'])) {
                $this->addUsingAlias(GotchaContentPeer::ID, $id['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($id['max'])) {
                $this->addUsingAlias(GotchaContentPeer::ID, $id['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(GotchaContentPeer::ID, $id, $comparison);
    }

    /**
     * Filter the query on the Strong_Name column
     *
     * Example usage:
     * <code>
     * $query->filterByStrongName('fooValue');   // WHERE Strong_Name = 'fooValue'
     * $query->filterByStrongName('%fooValue%'); // WHERE Strong_Name LIKE '%fooValue%'
     * </code>
     *
     * @param     string $strongName The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return GotchaContentQuery The current query, for fluid interface
     */
    public function filterByStrongName($strongName = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($strongName)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $strongName)) {
                $strongName = str_replace('*', '%', $strongName);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(GotchaContentPeer::STRONG_NAME, $strongName, $comparison);
    }

    /**
     * Filter the query on the Title column
     *
     * Example usage:
     * <code>
     * $query->filterByTitle('fooValue');   // WHERE Title = 'fooValue'
     * $query->filterByTitle('%fooValue%'); // WHERE Title LIKE '%fooValue%'
     * </code>
     *
     * @param     string $title The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return GotchaContentQuery The current query, for fluid interface
     */
    public function filterByTitle($title = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($title)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $title)) {
                $title = str_replace('*', '%', $title);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(GotchaContentPeer::TITLE, $title, $comparison);
    }

    /**
     * Filter the query on the Text column
     *
     * Example usage:
     * <code>
     * $query->filterByText('fooValue');   // WHERE Text = 'fooValue'
     * $query->filterByText('%fooValue%'); // WHERE Text LIKE '%fooValue%'
     * </code>
     *
     * @param     string $text The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return GotchaContentQuery The current query, for fluid interface
     */
    public function filterByText($text = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($text)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $text)) {
                $text = str_replace('*', '%', $text);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(GotchaContentPeer::TEXT, $text, $comparison);
    }

    /**
     * Filter the query on the Creation_Date column
     *
     * Example usage:
     * <code>
     * $query->filterByCreationDate('2011-03-14'); // WHERE Creation_Date = '2011-03-14'
     * $query->filterByCreationDate('now'); // WHERE Creation_Date = '2011-03-14'
     * $query->filterByCreationDate(array('max' => 'yesterday')); // WHERE Creation_Date > '2011-03-13'
     * </code>
     *
     * @param     mixed $creationDate The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return GotchaContentQuery The current query, for fluid interface
     */
    public function filterByCreationDate($creationDate = null, $comparison = null)
    {
        if (is_array($creationDate)) {
            $useMinMax = false;
            if (isset($creationDate['min'])) {
                $this->addUsingAlias(GotchaContentPeer::CREATION_DATE, $creationDate['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($creationDate['max'])) {
                $this->addUsingAlias(GotchaContentPeer::CREATION_DATE, $creationDate['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(GotchaContentPeer::CREATION_DATE, $creationDate, $comparison);
    }

    /**
     * Filter the query on the Creation_Title column
     *
     * Example usage:
     * <code>
     * $query->filterByCreationTitle('fooValue');   // WHERE Creation_Title = 'fooValue'
     * $query->filterByCreationTitle('%fooValue%'); // WHERE Creation_Title LIKE '%fooValue%'
     * </code>
     *
     * @param     string $creationTitle The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return GotchaContentQuery The current query, for fluid interface
     */
    public function filterByCreationTitle($creationTitle = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($creationTitle)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $creationTitle)) {
                $creationTitle = str_replace('*', '%', $creationTitle);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(GotchaContentPeer::CREATION_TITLE, $creationTitle, $comparison);
    }

    /**
     * Filter the query on the Gotcha_Users_Id column
     *
     * Example usage:
     * <code>
     * $query->filterByGotchaUsersId(1234); // WHERE Gotcha_Users_Id = 1234
     * $query->filterByGotchaUsersId(array(12, 34)); // WHERE Gotcha_Users_Id IN (12, 34)
     * $query->filterByGotchaUsersId(array('min' => 12)); // WHERE Gotcha_Users_Id >= 12
     * $query->filterByGotchaUsersId(array('max' => 12)); // WHERE Gotcha_Users_Id <= 12
     * </code>
     *
     * @see       filterByGotchaUsers()
     *
     * @param     mixed $gotchaUsersId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return GotchaContentQuery The current query, for fluid interface
     */
    public function filterByGotchaUsersId($gotchaUsersId = null, $comparison = null)
    {
        if (is_array($gotchaUsersId)) {
            $useMinMax = false;
            if (isset($gotchaUsersId['min'])) {
                $this->addUsingAlias(GotchaContentPeer::GOTCHA_USERS_ID, $gotchaUsersId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($gotchaUsersId['max'])) {
                $this->addUsingAlias(GotchaContentPeer::GOTCHA_USERS_ID, $gotchaUsersId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(GotchaContentPeer::GOTCHA_USERS_ID, $gotchaUsersId, $comparison);
    }

    /**
     * Filter the query by a related GotchaUsers object
     *
     * @param   GotchaUsers|PropelObjectCollection $gotchaUsers The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return                 GotchaContentQuery The current query, for fluid interface
     * @throws PropelException - if the provided filter is invalid.
     */
    public function filterByGotchaUsers($gotchaUsers, $comparison = null)
    {
        if ($gotchaUsers instanceof GotchaUsers) {
            return $this
                ->addUsingAlias(GotchaContentPeer::GOTCHA_USERS_ID, $gotchaUsers->getId(), $comparison);
        } elseif ($gotchaUsers instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(GotchaContentPeer::GOTCHA_USERS_ID, $gotchaUsers->toKeyValue('Id', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByGotchaUsers() only accepts arguments of type GotchaUsers or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the GotchaUsers relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return GotchaContentQuery The current query, for fluid interface
     */
    public function joinGotchaUsers($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('GotchaUsers');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'GotchaUsers');
        }

        return $this;
    }

    /**
     * Use the GotchaUsers relation GotchaUsers object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   \GotchaDatabase\GotchaUsersQuery A secondary query class using the current class as primary query
     */
    public function useGotchaUsersQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinGotchaUsers($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'GotchaUsers', '\GotchaDatabase\GotchaUsersQuery');
    }

    /**
     * Filter the query by a related GotchaPages object
     *
     * @param   GotchaPages|PropelObjectCollection $gotchaPages  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return                 GotchaContentQuery The current query, for fluid interface
     * @throws PropelException - if the provided filter is invalid.
     */
    public function filterByGotchaPages($gotchaPages, $comparison = null)
    {
        if ($gotchaPages instanceof GotchaPages) {
            return $this
                ->addUsingAlias(GotchaContentPeer::ID, $gotchaPages->getGotchaContentId(), $comparison);
        } elseif ($gotchaPages instanceof PropelObjectCollection) {
            return $this
                ->useGotchaPagesQuery()
                ->filterByPrimaryKeys($gotchaPages->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByGotchaPages() only accepts arguments of type GotchaPages or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the GotchaPages relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return GotchaContentQuery The current query, for fluid interface
     */
    public function joinGotchaPages($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('GotchaPages');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'GotchaPages');
        }

        return $this;
    }

    /**
     * Use the GotchaPages relation GotchaPages object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   \GotchaDatabase\GotchaPagesQuery A secondary query class using the current class as primary query
     */
    public function useGotchaPagesQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinGotchaPages($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'GotchaPages', '\GotchaDatabase\GotchaPagesQuery');
    }

    /**
     * Exclude object from result
     *
     * @param   GotchaContent $gotchaContent Object to remove from the list of results
     *
     * @return GotchaContentQuery The current query, for fluid interface
     */
    public function prune($gotchaContent = null)
    {
        if ($gotchaContent) {
            $this->addCond('pruneCond0', $this->getAliasedColName(GotchaContentPeer::ID), $gotchaContent->getId(), Criteria::NOT_EQUAL);
            $this->addCond('pruneCond1', $this->getAliasedColName(GotchaContentPeer::GOTCHA_USERS_ID), $gotchaContent->getGotchaUsersId(), Criteria::NOT_EQUAL);
            $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
        }

        return $this;
    }

}
